package com.cust.zy.newtask.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;
import android.widget.SimpleAdapter;

import com.cust.zy.newtask.R;
import com.cust.zy.newtask.model.Word;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by zhuangyuan on 4/14/2017.
 * 邮箱：zhuangyuan.k@qq.com
 */
public class GapReviewWordsActivity extends AppCompatActivity {

    private ListView wordList;

    private ArrayList<Word> data;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gap_review_words);
        final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("复习回顾");
        setSupportActionBar(toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        Intent intent = this.getIntent();
        data = intent.getParcelableArrayListExtra(KillWordsActivity.WORD_VIEW_DATA);
        List<Map<String, Object>> listData = new ArrayList<Map<String, Object>>();
        for (Word word :data) {
            Map<String, Object> map = new HashMap<String, Object>();
            map.put("word_name",word.getName());
            map.put("word_translation", word.getTranslation());
            listData.add(map);
        }
        wordList = (ListView) this.findViewById(R.id.gap_review_words);
        SimpleAdapter adapter = new SimpleAdapter(this, listData, R.layout.item_word_gap_review,
                new String[]{"word_name", "word_translation"},
                new int[]{R.id.word_name, R.id.word_translation});
        wordList.setAdapter(adapter);
        wordList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            }
        });
    }
}
